package com.icoolkj.mall.product.controller;

import com.icoolkj.mall.common.Result;
import com.icoolkj.mall.product.dto.ProductRequest;
import com.icoolkj.mall.product.dto.ProductResponse;
import com.icoolkj.mall.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author icoolkj
 * @version 1.0
 * @description
 * @createDate 2025/01/15 20:41
 */
//@CrossOrigin
@RestController
@RequestMapping("/api/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @PostMapping("/create-product")
    public Result<?> createProduct(@RequestBody ProductRequest productRequest){
        return productService.createProduct(productRequest);
    }

    @GetMapping("/get-all-products")
    public Result<?> getAllProducts(){
        return productService.getAllProducts();
    }

    @GetMapping("/get-price-product")
    public Result<ProductResponse> getPriceProduct(@RequestParam("productId") Long productId) {
        return productService.getPriceProduct(productId);
    }
}
